package study.optional.实战练习;

import java.util.Optional;

/**
 * @Author 刘伟涛
 * @Date 2023/7/6 9:26
 **/
public class OptionalUtility {
    public static Optional<Integer> stringToInt(String str){
        try {
            return Optional.of(Integer.parseInt(str));
        } catch (NumberFormatException e) {
            return Optional.empty();
        }
    }
}
